home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-16 | 467 b | 29 lines | [TEXT/CWIE] |
- //
- // Case-independent string comparison.
- //
-
- #include "UCIString.h"
- #include <ctype.h>
-
- int cistrcmp(const char *s, const char *t) {
- int sc, tc;
- for (;;) {
- sc = tolower(*s++);
- tc = tolower(*t++);
- if (sc != tc || sc == 0)
- break;
- }
- return sc - tc;
- }
-
- int cistrncmp(const char *s, const char *t, size_t n) {
- while (n-- > 0) {
- int sc = tolower(*s++);
- int tc = tolower(*t++);
- int d = sc - tc;
- if (d) return d;
- if (!sc) return 0;
- }
- return 0;
- }
-